// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

export async function deleteGoods(data: Array<number | string | undefined>) {
  return request<API.ResponseResult>('/api/xmbz-distribution/mallGoods/delete', {
    method: 'POST',
    data,
  });
}

export async function addGoods(data: { [key: string]: any }) {
  return request<API.ResponseResult>('/api/xmbz-distribution/mallGoods/insert', {
    method: 'POST',
    data
  });
}

export async function updateGoods(data: { [key: string]: any }) {
  return request<API.ResponseResult>('/api/xmbz-distribution/mallGoods/update', {
    method: 'POST',
    data
  });
}

export async function getGoodsList(params: { [key: string]: any }) {
  return request<API.ResponseResult>('/api/xmbz-distribution/mallGoods/listMallGoods', {
    method: 'GET',
    params,
  });
}

export async function getCategoryList() {
  return request<API.ResponseResult>('/api/xmbz-distribution/mallGoodsCategory/list', {
    method: 'GET',
  });
}

export async function getParseGoodsList(params: { [key: string]: any }) {
  const { current, pageSize } = params
  delete params.current
  delete params.pageSize
  return getGoodsList({
    page: current,
    size: pageSize,
    ...params
  }).then(res => {
    return {
      data: res.data.rows || [],
      total: res.data.total,
    }
  })
}